#include <iostream>
#include <fstream>
#include <ctime>

using namespace std;

int main()
{
    const int LEN = 5000;
    int a1[LEN], a2[LEN], a3[LEN], c = 0;
    
    ifstream bas("m1_sorted.txt");
    for(int i=0; i < a1[LEN]; i++) bas >> a1[i];
    
    unsigned int t_start = clock();
    
    for(int i=0; i < a1[LEN]; i++){
        bas >> a1[LEN];
        for(int j=0; j < a1[LEN] - i - 1; j++){
            if(a1[j] > a1[j+1]){
                c=a1[j];a1[j]=a1[j+1];a1[j+1]=c;
            }
        }
    }
    
    unsigned int t_finish = clock();
    unsigned int t_work = t_finish - t_start;
    cout<<"m1_sorted " << t_work << " milliseconds \n";

    bas.close();
    
    ifstream fin("m2_reverse.txt");
    for(int i=0; i < a2[LEN]; i++) fin >> a2[i];
    
    unsigned int k_start = clock();
    
    for(int i=0; i < a2[LEN]; i++){
        fin >> a2[LEN];
        for(int j=0; j < a2[LEN] - i - 1; j++){
            if(a2[j] > a2[j+1]){
                c=a2[j];a2[j]=a2[j+1];a2[j+1]=c;
            }
        }
    }
    
    unsigned int k_finish = clock();
    unsigned int k_work = k_finish - k_start;
    cout<<"m2_reverse " << k_work << " milliseconds \n";
    
    fin.close();
    
    ifstream fon("m3_shuffle.txt");
    for(int i=0; i < a3[LEN]; i++) fon >> a3[i];
    
    unsigned int j_start = clock();
    
    for(int i=0; i < a3[LEN]; i++){
        fon >> a3[LEN];
        for(int j=0; j < a3[LEN] - i - 1; j++){
            if(a3[j] > a3[j+1]){
                c=a3[j];a3[j]=a3[j+1];a3[j+1]=c;
            }
        }
    }
    
    unsigned int j_finish = clock();
    unsigned int j_work = j_finish - j_start;
    cout<<"m3_shuffle " << j_work << " milliseconds \n";
    
    fon.close();
    return 0;
}
